package com.yc.system.controller;

import java.util.List;

import com.yc.system.entity.User;
import com.yc.system.mapper.BookTvMapper;
import com.yc.system.vo.TvInfo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;

import  com.yc.system.service.IBookTvService;


import org.springframework.web.bind.annotation.RestController;
import com.yc.framework.baseClass.BaseController;
//import com.yc.framework.baseClass.ServiceFacade;
import com.yc.framework.baseClass.R;
import com.yc.system.entity.BookTv;
/**
 * <p>
    * 公告 前端控制器
    * </p>
 *
 * @author 1850140986@qq.com
 * @since 2022-12-03
 */
@RestController
public class BookTvController extends BaseController
    {

    @Autowired
  private IBookTvService service;

    @Autowired
	public BookTvMapper mapper;

  /**
   * 根据条件分页查询BookTv
   * @param model 实体对象
   * @return 查询列表
   */
     @PostMapping("/list")
    public R list(@RequestBody BookTv model){
        return service.list(model);

    }

    /**
    * 根据主键查询单个对象
    * @param model 实体对象包含uuid
    * @return 成功或失败
    */
    @GetMapping("/getById/{id}")
    public R getById(@PathVariable String id) {
        return service.getModelById(id);
    }

    /**
	 * 新增实体对象
	 *
     * @param model 实体对象
	 * @return 新增是否成功
	 */
     @PostMapping("/save")
	public R save(@RequestBody BookTv model) {
		return service.saveModel(model);

	}

    /**
	 * 批量新增实体对象
	 *
     * @param modelList 实体对象列表
	 * @return 新增是否成功
	 */
	@PostMapping("/saveBatch")
	public R saveBatch(@RequestBody List<BookTv> modelList) {
		return service.saveModelBatch(modelList);

	}

    /**
	 * 根据主键删除实体
	 *
     * @param uuid 实体携带主键
	 * @return 删除是否成功
	 */
	@DeleteMapping("/removeById/{id}")
	public R removeById(@PathVariable String id) {
		return service.removeModelById(id);
	}

     /**
	 * 根据主键列表删除实体
	 *
     * @param idList 实体主键
	 * @return 删除是否成功

	@DeleteMapping("/removeByIdList")
	public R removeByIdList(@RequestBody List<BookTv> idList) {
        return service.removeModelByIdList(idList);

    }
 */
    /**
    * 根据主键修改实体
    *
    * @param model 等待修改的对象
    * @return 修改是否成功
    */
    @PutMapping("/updateById")
    public R updateModelById(@RequestBody BookTv model) {
        return service.updateModelById(model);

    }

    /**
    * 根据主键列表修改实体列表
    *
    * @param modelList 等待修改的对象列表
    * @return 修改是否成功
    */
    @PostMapping("/updateByIdBatch")
    public R updateModelByIdBatch(@RequestBody List<BookTv> modelList) {
        return service.updateModelByIdBatch(modelList);

    }

      /**
	 * 根据多主键列表删除实体
	 *
     * @param idList 多主键
	 * @return 删除是否成功
	 */
	@DeleteMapping("/removeByIds/{ids}")
	public R removeByIdList(@PathVariable String ids) {
        return service.removeModelByIds(ids);

    }

		@PostMapping("index/sys/bookTv/getTVsByPage")
		public R getTVsByPage(@RequestBody TvInfo user) {
			return service.getTVsByPage(user);
		}

		@PostMapping("sys/bookTv/deleteById")
		public R deleteById(@RequestBody TvInfo tv) {
		int i = mapper.deleteByTvId(tv.getTvId());
			return i==1?R.ok():R.err();
		}

		@PostMapping("sys/bookTv/update")
		public R update(@RequestBody TvInfo tv) {
			int i = mapper.updateByTvId(tv);
			return i==1?R.ok():R.err();
		}

		@PostMapping("sys/bookTv/add")
		public R add(@RequestBody TvInfo tv) {
			return service.saveModel(tv);
			 
		}

}
